package AdapterAndFacade.Adapters;

import AdapterAndFacade.AdapterInterfaces.Duck;
import AdapterAndFacade.AdapterInterfaces.Turkey;

import java.util.Random;

/**
 * @Author: pengzx
 * @Description:
 * @Date: 10:53 2017/9/14
 * @Modified by: 1.0
 */
public class DuckAdapter implements Turkey {
    Duck duck;
    Random random;
    @Override
    public void gobble()
    {
        duck.quack();
    }

    @Override
    public void fly()
    {
        if (random.nextInt(5)==0){
            duck.fly();
        }
    }

    public DuckAdapter(Duck duck)
    {
        this.duck = duck;
        random = new Random();
    }
}
